/**
 * 
 */
package com.kylin.frame.core.handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.handler.Handler;
import com.kylin.erp.oa.system.service.SystemMenuService;
import com.kylin.frame.util.ContantsUtil;
import com.kylin.frame.util.SpringContextUtil;
import com.kylin.frame.util.WebUtils;

/**
 * 常用属性，每个页面都可以通过freemarker来调用。
 * @todo 后续需要从缓存中来获取。
 * @author huxiang
 * 
 */
public class CommonAttrHandler extends Handler {

	private SystemMenuService systemMenuService;

	public void handle(String target, HttpServletRequest request,
			HttpServletResponse response, boolean[] isHandled) {
		systemMenuService = SpringContextUtil.getApplicationContext().getBean(
				SystemMenuService.class);
		request.setAttribute("_REAL_PATH",
				ContantsUtil._REALPATH + request.getContextPath());
		request.setAttribute("_BASE_PATH", request.getContextPath());
		request.setAttribute("_SITE_NAME", "金麟龙腾信息管理系统");
		request.setAttribute("_systemMenus", systemMenuService.getUserMenus(0));
		request.setAttribute(ContantsUtil._SESSIONOB,
				WebUtils.getSessionAttribute(request, ContantsUtil._SESSIONOB));
		nextHandler.handle(target, request, response, isHandled);
	}

}
